<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link th:href="@{/erp/assets/css/bootstrap.min.css}" rel="stylesheet"/>
    <link rel="stylesheet" th:href="@{/erp/css/style.css}"/>
    <link th:href="@{/erp/assets/css/codemirror.css}" rel="stylesheet">
    <link rel="stylesheet" th:href="@{/erp/assets/css/ace.min.css}"/>
    <link rel="stylesheet" th:href="@{/erp/assets/css/font-awesome.min.css}"/>
    <script th:src="@{/erp/assets/js/jquery.min.js}"></script>
    <script th:src="@{/erp/assets/js/bootstrap.min.js}"></script>
    <!-- page specific plugin scripts -->
    <script th:src="@{/erp/assets/js/jquery.dataTables.min.js}"></script>
    <script th:src="@{/erp/assets/js/jquery.dataTables.bootstrap.js}"></script>
    <script th:src="@{/erp/assets/layer/layer.js}" type="text/javascript"></script>
</head>
<body>


<form>
    <!--编辑区域分配图层-->
    <div class="edit_menber" id="edit_menber_style">
        <input th:value="${param.warehouseId}" id="iid" type="hidden">
        <input th:value="${param.id}" name="id" type="hidden">
        <ul class=" page-content">
            <div class="Operate_cont clearfix">
                <div class="brand_detailed">
                    <ul class="Info_style clearfix" style="width:510px; margin-top:0px;">
                        <li><label class="label_name">货区编号：</label>
                            <span class="name">
                                <input required th:value="${param.areaNo}"  id="areaNo" name="areaNo" type="text" class="text_add" style="width:140px;" >
                            </span>
                        </li>
                        <li><label class="label_name">货区名称：</label>
                            <span class="name">
                                <input required th:value="${param.areaName}"  name="areaName" type="text" class="text_add"  style="width:140px;" value="成品区" >
                            </span>
                        </li>
                        <li><label class="label_name">所属仓库：</label>
                            <span class="name">
                                 <!--下拉框-->
                                <select name="warehouseId" required id="warehouseName" style="margin-left:10px;">
                                    <option value="" selected disabled>--请选择仓库--</option>
                                </select>
                            </span>
                        </li>
                        <li><label class="label_name">负责人：</label>
                            <span class="name">
                            <input name="" readonly th:value="${param['warehouse[warehousePerson]']}" type="text"
                                   class="text_add" style="width:140px;" >
                             </span>
                        </li>
                        <li><label class="label_name">联系电话：</label>
                            <span class="name">
                            <input name="" type="text"  readonly th:value="${param['warehouse[personTel]']}" class="text_add"
                                   style="width:140px;" >
                        </span>
                        </li>
                        <!-- <li><label class="label_name">货区数目：</label>
                             <span class="name">
                                 <input  type="text" class="text_add"  style="width:140px;" value="4"  >
                             </span>
                         </li>-->
                        <li><label class="label_name">货架数目：</label>
                            <span class="name">
                                <input name="shelfNum" readonly th:value="${param.shelfNum}" type="text" class="text_add"  style="width:140px;" value="52"  ></span></li>
                        <li><label class="label_name">货位数目：</label>
                            <span class="name">
                                <input name="" readonly th:value="${param.csNum}" type="text" class="text_add"  style="width:140px;" value="1464"  >
                            </span>
                        </li>
                        <li><label class="label_name">区域面积：</label>
                            <span class="name">
                                <input name="areaMj" required th:value="${param.areaMj}" type="text" class="text_add"  style="width:100px;" value="200"  >平方米</span></li>

                        <li><label class="label_name">创建时间：</label>
                            <span class="name" th:text="${param.createTime}"></span>
                        </li>
                        <li><label class="label_name">状态：</label>
                            <div th:if="${param.areaStatus[0]} eq '1' ">
                                <input type="radio"  th:value="1" checked class="input-text" placeholder="" name="areaStatus">已启用
                                &nbsp;&nbsp; <input type="radio"  th:value="2" class="input-text" placeholder="" name="areaStatus">已停用
                            </div>
                            <div th:if="${param.areaStatus[0]} eq '2' ">
                                <input type="radio"  th:value="1"  class="input-text" placeholder="" name="areaStatus">已启用
                                &nbsp;&nbsp; <input type="radio"  th:value="2" checked class="input-text" placeholder="" name="areaStatus">已停用
                            </div>
                        </li>
                        <li class="b_Introduce"><label class="label_name">仓库描述：</label><br/>
                            <span class="name">
                                <textarea  cols="40" rows="8" th:text="${param.areaRemark}" required
                                                          name="areaRemark"></textarea></span></li>
                    </ul>
                    <div class="" style=" text-align:center">
                        <input class="btn btn-primary" id="tijiao" type="submit" value="提交">
                        <input class="btn btn-primary" id="tijiao1" type="reset" value="取消">
                    </div>
                </div>
            </div>
        </ul>
    </div>
</form>
<script>
    jQuery(function ($) {
        var iid = $("#iid").val();
        $.ajax({
            url: '/warehouse/list',
            type: 'post',
            success: function (res) {
                for (var i = 0; i < res.length; i++) {
                    if (iid == res[i].id) {
                        $("#warehouseName").append('<option selected value="' + res[i].id + '">' + res[i].warehouseName + '</option>')
                    } else {
                        $("#warehouseName").append('<option  value="' + res[i].id + '">' + res[i].warehouseName + '</option>')
                    }

                }
            }
        })

        $('form').submit(function () {
            var data = $('form').serialize();
            $.ajax({
                url: '/area/update',
                type: 'post',
                data: data,
                success: function (res) {
                    if (res.rs) {
                        parent.layer.msg(res.msg, {icon: 1});
                        $('#btn',parent.window.document).click();
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }
            })
            return false;
        });

        $('#tijiao1').on('click', function () {
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭
        });
    });

</script>
</body>
</html>